﻿using System;
using System.Runtime.Serialization;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Practices.Repository.Oracle
{
    /// <summary>
    /// Use this exception for ORA-1017: invalid username/password; logon denied.
    /// </summary>
    [Serializable()]
    [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Username")]
    public class OracleUsernamePasswordException : RepositoryException
    {
        /// <summary>
        /// The <see cref="OracleUsernamePasswordException"/> message string.
        /// </summary>
        [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Username")]
        public static readonly string InvalidUsernamePasswordMessage =
            @"The username and/or password provided in the configuration file does not match" +
            " the current Oracle username and/or password.";

        /// <summary>
        /// Initializes a new instance of the <see cref="OracleUsernamePasswordException"/> class.
        /// </summary>
        public OracleUsernamePasswordException()
            : base(OracleUsernamePasswordException.InvalidUsernamePasswordMessage)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="OracleUsernamePasswordException"/> class 
        /// with a specified error message.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public OracleUsernamePasswordException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="OracleUsernamePasswordException"/> class
        /// with a specified error message and a reference to the inner exception that is the cause of this exception.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.</param>
        public OracleUsernamePasswordException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="OracleUsernamePasswordException"/> class
        /// with serialiazation information and a streaming context.
        /// </summary>
        /// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about 
        /// the exception being thrown.</param>
        /// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about 
        /// the source or destination.</param>
        protected OracleUsernamePasswordException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
    }
}
